package com.william.jdbcplus.core.dialects.meta;

import com.william.jdbcplus.core.util.JdbcUtil;
import com.william.jdbcplus.core.util.datameta.DatabaseMetaInfo;
import com.william.jdbcplus.core.util.datameta.TableMetaInfo;
import com.william.jdbcplus.common.enums.DbType;

import javax.sql.DataSource;

public class MetaUtil {
    public static DatabaseMetaInfo getDatabaseInfo(DataSource ds) {
        DbType dbType = JdbcUtil.getDbType(ds);
        IMeta meta = MetaFactory.getInstance(dbType);
        return meta.getDbMeta(ds);
    }

    public static TableMetaInfo getTableInfo(DataSource ds, String tableName) {
        DbType dbType = JdbcUtil.getDbType(ds);
        IMeta meta = MetaFactory.getInstance(dbType);
        return meta.getTableMeta(ds, tableName);
    }
}
